﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HCFramework.API.LINQ;

namespace C
{
    public class Order_ProductController
    {
        public static void Insert(Order_Product a)
        {
            HCDataContext db = new HCDataContext();
            db.Order_Products.InsertOnSubmit(a);
            db.SubmitChanges();
        }

        public static void Update(Order_Product a, HCDataContext db)
        {
            db.SubmitChanges();
        }

        public static void Delete(int id)
        {
            throw new Exception("Không cho phép xóa Order_Product");

            //HCDataContext db = new HCDataContext();
            //Order_Product a = db.Order_Products.Where(
            //    ik => ik.ID == id).First();
            //db.Order_Products.DeleteOnSubmit(a);
            //db.SubmitChanges();
        }

        public static Order_Product GetByID(int id, HCDataContext db)
        {
            return db.Order_Products.Where(
                ik => ik.ID == id).FirstOrDefault();
        }

        public static Order_Product GetByID(int id)
        {
            return GetByID(id, new HCDataContext());
        }
    }
}